package com.gym.service.impl;

import com.gym.dao.EquipmenttypeDao;
import com.gym.service.EquipmenttypeService;
import com.gym.vo.EquimenttypeVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EquipmenttypeServiceImpl implements EquipmenttypeService {

    @Resource
    private EquipmenttypeDao equipmenttypeDao;

    /**
     * 查询所有分类信息
     * @return
     */
    @Override
    public List<EquimenttypeVo> selAllType() {
        //查询一级分类
        List<EquimenttypeVo> type1 = equipmenttypeDao.selAllType(0);
        System.err.println("type1:"+type1);
        for (EquimenttypeVo t1:type1) {
            //查询二级分类
            List<EquimenttypeVo> type2 = equipmenttypeDao.selAllType(t1.getEqutypeid());
            System.err.println("type2:"+type2);
            t1.setTypes2(type2);
            for (EquimenttypeVo t2:type2) {
                //查询三级分类
                List<EquimenttypeVo> type3 = equipmenttypeDao.selAllType(t2.getEqutypeid());
                System.err.println("type3:"+type3);
                t2.setTypes3(type3);
            }
        }
        return type1;
    }

    @Override
    public List<EquimenttypeVo> selEquTypeNums() {
        return equipmenttypeDao.selEquTypeNums();
    }
}
